<template>
  <el-form :model="form" label-width="auto" style="max-width: 600px">
    <el-form-item label="用户名">
      <el-input v-model="form.username" placeholder="请输入用户名" />
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="form.password" type="password" placeholder="请输入密码" show-password />
    </el-form-item>
    <el-form-item label="邮箱">
      <el-input v-model="form.email" placeholder="请输入邮箱" />
    </el-form-item>
    <el-form-item label="用户性别">
      <el-select v-model="form.sex" placeholder="选择性别">
        <el-option label="男" value="男" />
        <el-option label="女" value="女" />
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button align="center" type="primary" @click="onSubmit">提交</el-button>
      <el-button align="center" @click="cancel">取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import { defineEmits } from "vue";

import { ref } from "vue";
import requestUtil from "@/api/request.js";
import { ElMessage } from "element-plus";
let form = ref({
  username: '',
  password: '',
  email: '',
  sex: ''
});

const emits = defineEmits(["cancel", "submit"]);
const cancel = () => {
  emits("cancel");
};
const onSubmit = async () => {
  let res = await requestUtil.post("management/updateUserInfo/",form.value);
  if (res.data.code === 200) {
    ElMessage.success("添加成功");
    emits("submit");
  }
  
};
</script>